<template>
	<view class="detail">
		<view class="detail-box">
			<image :src="info.avatar" mode="" class="logo"></image>
			<view class="company-name">{{info.name}}</view>
			<view class="intrduce" v-html="article">
			</view>
		

		</view>
		<view class="other-info">
			<view class="other-info-list flex flai fljcsb">
				<text>跑腿费用</text>
				<text>{{info.errandPrice}}元/件商品</text>
			</view>
			<view class="other-info-list flex flai fljcsb">
				<text>快递费用</text>
				<text>{{info.emsPrice}}元/个快递包裹</text>
			</view>
		</view>
		<view class="btn" @click="selectCompany">选择此公司</view>
	</view>
</template>

<script>
	import API from '../../api/index.js'


	export default {
		data() {
			return {
				info:{},
				id:null,
				article:""
			}
		},
		onLoad(opt) {
			this.id = opt.id
			this.getDetail()
		},
		methods:{
			selectCompany() {
				 uni.setStorageSync('companyInfo',this.info)
				 API.indexHome.selectCompany({errandId:this.id}).then(res=>{
				 	if (res.errno==0) {
				 		uni.switchTab({
				 		    url: '/pages/writeOrder/writeOrder'
				 		});
				 	}
				 })
			
			},
			getDetail () {
				API.indexHome.getCompanyDetail({id:this.id}).then(res=>{
					if (res.errno=='0') {
						this.info = res.data
						this.article = res.data.content.replace(/\<img/gi, '<img class="richImg"')
					}
				})
			}
		}
	}
</script>
<style>
@import url("./detail.css");
rich-text {
	word-wrap:break-word;
	max-width: 100%;
}
rich-text .richImg {
	max-width: 100%;
	height: auto;
}
</style>
